<template>
  <div id="statisWrap" v-loading="loading" class="wrap">
    <div class="planTitleWrap">
      <div>
        <span style="color:#1f2f3d;font-size: 18px; font-weight: bold;">{{nowPlan.plan_title}}(
          {{nowPlan.completion_ratio}})</span> <span
          :class="{red:nowPlan.status==0||nowPlan.status==1,green:nowPlan.status==3}">{{isStatusStr[nowPlan.status]}}</span>
      </div>
      <el-button size="medium" icon="el-icon-arrow-left" @click="back">返回</el-button>
    </div>
    <el-tabs v-model="activeName">
      <div class="tabHead">
        <div class='tabHeadTab'>
          <div style="display: flex;align-items: center;">
            <div :class="{'el-tabs__item':true,'is-active':activeName =='first'}" @click="activeName='first'"><i
                class="el-icon-date"></i> 完成明细表</div>
            <div :class="{'el-tabs__item':true,'is-active':activeName =='second'}" @click="goSecond"><i
                class="el-icon-user-solid"></i> 评价对象统计表</div>
          </div>
        </div>
      </div>
      <div style="padding: 0px 10px 20px;">
        <el-tab-pane name="first">
          <el-form :inline="true" :model="searchA" class="search" @keyup.enter.native="reList" style="height:auto">
            <el-form-item v-if="planType==2">
              <el-select v-model="searchA.grade_id" @change="gradeChange">
                <el-option v-for="(it,index) in allGrade" :key="index" :value="it.value" :label="it.label">
                  {{it.label}}
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item v-if="planType==2">
              <el-select v-model="searchA.class_id" @change="reList" style="width: 108px;">
                <el-option v-for="(item,index) in getNowAllClass" :key="index" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item v-if="planType==1">
              <el-select v-model="searchA.dept_id" @change="reList" style="width: 108px;">
                <el-option v-for="(item,index) in allLeftDep" :key="index" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="">
              <el-select v-model="searchA.is_finish" placeholder="请选择状态" @change="reList">
                <el-option label="全部状态" value=""></el-option>
                <el-option label="已完成" value="1"></el-option>
                <el-option label="未完成" value="0"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button v-if="admin&&(nowPlan.status==0||nowPlan.status==1)" size="small" type="primary"
                @click="add">新增评价人</el-button>
            </el-form-item>
          </el-form>
          <el-table style="width: 100%" :data="tableData" border align="center" highlight-current-row stripe>
            <el-table-column prop="user_name" label="填写人"></el-table-column>
            <el-table-column prop="finish_time" label="评价完成时间" align="center">
              <template slot-scope="scope">
                {{scope.row.finish_time==null?'未完成':scope.row.finish_time}}
              </template>
            </el-table-column>
            <el-table-column prop="completion_ratio" label="填写状态" align="center" >
              <template slot-scope="scope">
                  <el-link  type="primary" slot="reference" size="small" @click="getAllStatus(scope.row)"
                    :title="'查看【'+scope.row.user_name +'】填写状态明细'">{{scope.row.completion_ratio}}</el-link>
              </template>
            </el-table-column>
            <el-table-column v-if="this.nowPlan.eval_from_to" prop="grade_name" label="年级" align="center">
            </el-table-column>
            <el-table-column v-if="this.nowPlan.eval_from_to" prop="class_name" label="班级" align="center">
            </el-table-column>
            <el-table-column v-if="!this.nowPlan.eval_from_to" prop="dept_name" label="部门" align="center">
            </el-table-column>
            <el-table-column fixed="right" label="操作" width="120" align="center">
              <template slot-scope="scope">
                <!-- <el-popconfirm title="是否删除评价人吗？" @confirm="handleDel(scope.row)"> -->
                  <el-link v-if="nowPlan.status!==3" type="danger" slot="reference" size="small" @click="handleDel(scope.row)"
                    :title="'删除【'+scope.row.user_name +'】'">删除</el-link>
                <!-- </el-popconfirm> -->
                <el-link v-if="nowPlan.status==3" disabled slot="reference" size="small"
                  :title="'删除【'+scope.row.user_name +'】'">删除</el-link>
              </template>
            </el-table-column>
          </el-table>
          <!-- 分页 -->
          <el-pagination :currentPage=searchA.pageNo :page-size=searchA.pageSize :page-sizes="[10, 20,40, 50, 100]"
            :hide-on-single-page="aTotal==0" layout="total, sizes, prev, pager, next, jumper" :total="aTotal"
            @size-change="handleSizeChange" @current-change="handleCurrentChange">
          </el-pagination>
        </el-tab-pane>

        <el-tab-pane name="second">
          <el-form :inline="true" :model="searchB" class="search" @keyup.enter.native="reList" style="height:auto">
            <!-- <el-form-item>
            <el-select v-model="searchB.grade_id" @change="gradeBChange" >
              <template  v-for="(it,index) in allGrade" >
                    <el-option :key="index" :value="it.value" :label="it.label">
                        {{it.label}}
                    </el-option>
              </template>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-select v-model="searchB.class_id" @change="rightList"  style="width: 108px;">
              <el-option
                v-for="(item,index) in getNowAllClass"
                :key="index"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item> -->
            <el-form-item>
              <el-select v-model="searchB.dept_id" @change="rightList" style="width: 108px;">
                <el-option v-for="(item,index) in allRightDep" :key="index" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="">
              <el-select v-model="searchB.is_finish" placeholder="请选择状态" @change="rightList">
                <el-option label="全部状态" value=""></el-option>
                <el-option label="已完成" value="1"></el-option>
                <el-option label="未完成" value="0"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" size="small" @click="downFile(1)">导出当前表</el-button>
            </el-form-item>
          </el-form>
          <!-- <template slot-scope="scope">
                  {{scope.row[item.key]}}
                </template> -->
          <el-table style="width: 100%" :data="tableRightData" border align="center" show-overflow-tooltip
            highlight-current-row stripe table-layout='auto'>
            <el-table-column v-for="(item) in tabledHead" :prop="item.key" :key="item.key" :label="item.title"
              align="center">
            </el-table-column>
            <el-table-column fixed="right" label="操作" align="center">
              <template slot-scope="scope">
                <el-link type="primary" @click="handleRightDetail(scope.row)" slot="reference" size="small"
                  :title="'查看【'+scope.row.key0 +'】的评价统计'">评价统计</el-link>
                <el-link v-show="times" type="primary" @click="refresh(scope.row)" slot="reference" size="small"
                  :title="'刷新【'+scope.row.key0 +'】的评价统计'">刷新</el-link>
              </template>
            </el-table-column>
          </el-table>
          <!-- 分页 -->
          <el-pagination :currentPage=searchB.pageNo :page-size=searchB.pageSize :page-sizes="[10, 20,40, 50, 100]"
            :hide-on-single-page="bTotal==0" layout="total, sizes, prev, pager, next, jumper" :total="bTotal"
            @size-change="handleORSizeChange" @current-change="handleORCurrentChange">
          </el-pagination>
        </el-tab-pane>
      </div>
    </el-tabs>
    <!-- 密码窗口 -->
    <el-dialog title="访问密码" :visible.sync="dialogPSVisible" width="36%" height="240">
      <el-form :model="PSForm" :rules="rules" label-position="top" ref="PSForm" label-width="180px" id="PSWrap">
        <el-form-item label="请输入访问密码" prop="password" style="width:480px;display: flex;">
          <el-input v-model="PSForm.password" autocomplete="off" placeholder="请输入访问密码" maxlength="6" show-password
            style="width: 280px;"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogPSVisible = false">取 消</el-button>
        <el-button type="primary" @click="verifyPS">确定访问</el-button>
      </div>
    </el-dialog>
    <!-- 密码窗口 end -->
    <!-- 统计详情窗口 -->
    <el-dialog title="评价统计表" :visible.sync="dialogStatisticsIsible" width="800">
      <div id="statisWrap">
        <div class="teacherInfoWrap"><i class="el-icon-user-solid"></i> <span
            class="teacherName">{{nowViewTeacher.name}}</span>({{ nowViewTeacher.mob }})</div>
        <el-tabs v-model="editableTabsValue" @tab-click="handleTabsEdit">
          <el-tab-pane :key="item.name" v-for="(item) in allLabels" :label="item.name" :name="item.labelId"
            style='height:360px;overflow: auto;'>
            <el-table style="width: 100%" :data="questionData" :span-method="objectSpanMethod" border align="center"
              show-overflow-tooltip highlight-current-row stripe table-layout='auto'>
              <el-table-column prop="type" label="题型" width="70" align="center">
                <template slot-scope="scope">
                  {{allQType[scope.row.type]}}
                </template>
              </el-table-column>
              <el-table-column prop="question_title" label="问题">
                <template slot-scope="scope">
                  <span class="red">{{ scope.row.is_required?'*':''
                    }}</span>{{scope.row.SN}}.{{scope.row.question_title}}?
                </template>
              </el-table-column>
              <el-table-column prop="question_option_title" label="选项">
                <template slot-scope="scope">
                  {{ scope.row.type==3?'':allSN[scope.row.index]+'.'+scope.row.question_option_title}}
                </template>
              </el-table-column>
              <el-table-column prop="answerCount" label="填写人数" width="80" align="center"></el-table-column>
              <el-table-column prop="answerPercent" label="占比" width="80" align="center">
                <template slot-scope="scope">
                  {{scope.row.answerPercent==null?'-':scope.row.answerPercent+'%'}}
                </template>
              </el-table-column>
              <el-table-column label="操作" width="100" align="center">
                <template slot-scope="scope">
                  <el-link type="primary" :disabled="nowPlan.is_hidden"
                    @click="!nowPlan.is_hidden ? submitterInfo(scope.row, 2) : null" size="small" :title="nowPlan.is_hidden
                      ? '匿名计划不能查看【' + scope.row.question_title + '】提交人明细'
                      : '查看【' + scope.row.question_title + '】提交人明细'">
                    查看
                  </el-link>

                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
        </el-tabs>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogStatisticsIsible = false">取 消</el-button>
        <!-- <el-button type="primary" @click="verifyPS">确定访问</el-button> -->
      </div>
    </el-dialog>
    <el-dialog title="提交人明细表" :visible.sync="dialogSubmitterIsible" width="800">
      <div id="statisWrap" v-loading="submitterLoading">
        <div class="teacherInfoWrap"><span class="teacherName">{{nowQuestion}} ?</span></div>
        <el-tabs v-model="submitterTabsValue" @tab-click="handleTabsclick">
          <el-tab-pane :key="item.id" v-for="(item) in allOPLabels" :label="item.name" :name="item.id">
            <el-table style="width: 100%" :data="item.data" border align="center" show-overflow-tooltip
              highlight-current-row stripe table-layout='auto'>
              <el-table-column prop="user_name" label="填写人" width="100" align="center">
              </el-table-column>
              <el-table-column v-if="nowPlan.eval_from_to" prop="grade_name" label="年级">
              </el-table-column>
              <el-table-column v-if="nowPlan.eval_from_to" prop="class_name" label="班级">
              </el-table-column>
              <el-table-column v-if="!nowPlan.eval_from_to" prop="dept_name" label="部门"
                align="center"></el-table-column>
                <el-table-column v-if="item.type==3" prop="answer" label="答案"
                align="center"></el-table-column>
            </el-table>
            <el-pagination :currentPage=item.pageNo :page-size=item.pageSize :page-sizes="[10, 20,40, 50, 100]"
              :hide-on-single-page="item.total==0" layout="total, sizes, prev, pager, next, jumper" :total="item.total"
              @size-change="submitterSizeChange($event,item)" @current-change="submitterCurrentChange($event,item)">
            </el-pagination>
          </el-tab-pane>
        </el-tabs>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogSubmitterIsible = false">取 消</el-button>
        <!-- <el-button type="primary" @click="verifyPS">确定访问</el-button> -->
      </div>
    </el-dialog>
    <!-- 统计详情窗口 end -->
    <!-- 添加窗口 -->
    <el-dialog title="添加评价人" :visible.sync="addDialogView" width="640">
      <el-form ref="addForm" :model="addForm" label-width="80px" v-loading="addLoading">
        <div label="填写人员" style="padding:10px 0;display: flex;">
          <span style="padding-right: 10px;font-weight: bold;">填写人员</span>
          <el-link type="primary" @click="addAppraiser">{{addForm.name||'请选择评价人'}}</el-link>
        </div>
        <div class="transferWrap" style="display: flex;margin-top: 10px;justify-content: space-between;overflow: auto;">
          <div class="el-transfer-panel add-transfer" v-for="(it, index) in addForm.to" v-bind:key="index">
            <div class="el-transfer-panel__header"
              style="display: flex;padding-right: 15px;justify-content: space-between;">
              <div>{{it.label_title}}</div>
            </div>
            <div style="margin: 20px;height:300px;overflow-y: auto; margin-right: 10px;padding-right: 10px;">
              <div v-for="(item, index) in it.add" :key="index" class="oneChangedStu">
                <div>{{item.label}}(<span class="remark">{{item.mob}}</span>)</div>
                <el-link type="danger" title="移除" @click="removeNowTeacher(index,it.add)">移除</el-link>
              </div>
              <el-empty v-if="it.add.length==0" description="未选择"></el-empty>
            </div>
            <p class="el-transfer-panel__footer">
              <el-button size="mini" type="primary" plain :title="'为【'+it.label_title+'】添加被评价对象'"
                :loading="nowLabelLoading" @click="handleAdd(it)">添加</el-button>
              <el-button type="danger" size="mini" @click="removeAllTeacher(it)"
                :title="'清空【'+it.label_title+'】已添加被评价对象'">清空</el-button>
            </p>
          </div>
        </div>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="addDialogView = false">取 消</el-button>
        <el-button type="primary" @click="addAll" v-loading="addLoading">确认添加</el-button>
      </span>
    </el-dialog>
    <el-dialog title="选择评价人" :visible.sync="addAppraiserDialog" width="480">
      <div class="transferWrap" style="display: flex;margin-top: 10px;justify-content: space-between;">
        <div class="el-transfer-panel" style="width:100%;">
          <div style="padding: 10px  20px  20px;">
            <el-input placeholder="输入关键字进行过滤" prefix-icon="el-icon-search" clearable v-model="appraiserFilterText"
              style="margin: 10px 0;">
            </el-input>
            <div style="height: 360px;overflow-y: auto;">
              <el-tree :data="appraiserDialogData" node-key="id" ref="tree" accordion highlight-current
                :filter-node-method="filterNode" :render-content="renderContent" :props="defaultProps">
              </el-tree>
            </div>
          </div>
        </div>
      </div>
    </el-dialog>

    <el-dialog title="被评价对象" :visible.sync="addBeEvaluatedDialog" width="640">
      <div class="transferWrap" style="display: flex;margin-top: 10px;justify-content: space-between;">
        <div class="el-transfer-panel">
          <div class="el-transfer-panel__header"
            style="display: flex;padding-right: 15px;justify-content: space-between; align-items: center;">
            <div>可选择</div>
            <el-checkbox v-model="checkAll" @change="handleCheckAllChange"
              style="font-size: 12px;display:flex;align-items: center;">全选</el-checkbox>
          </div>
          <div style="padding: 10px  20px  20px;;">
            <el-input placeholder="输入关键字进行过滤" prefix-icon="el-icon-search" clearable v-model="filterText"
              style="margin: 10px 0;">
            </el-input>
            <div style="height: 360px;overflow-y: auto;">
              <el-tree :data="teachers" show-checkbox node-key="id" ref="teacherTree" accordion highlight-current
                :filter-node-method="filterNode" @check="handleNodeClick" :props="defaultProps">
              </el-tree>
            </div>
          </div>
        </div>
        <div class="el-transfer-panel">
          <div class="el-transfer-panel__header"
            style="display: flex;padding-right: 15px;justify-content: space-between;">
            <div>已选择({{changedObj.length}})</div>
            <el-link type="danger" title="清空已选择" @click="resetChecked">清空</el-link>
          </div>
          <div style="margin: 20px;height:380px;overflow-y: auto; margin-right: 10px;padding-right: 10px;">
            <div v-for="(item, index) in changedObj" :key="index" class="oneChangedStu">
              <div>{{item.label}}(<span class="remark">{{item.mob}}</span>)</div>
              <el-link type="danger" title="移除" @click="remove(item.id)">移除</el-link>
            </div>
            <el-empty v-if="changedObj.length==0" description="未选择"></el-empty>
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="addBeEvaluatedDialog = false">取 消</el-button>
        <el-button type="primary" :disabled="changedObj.length==0" @click="sureTeachers">确定</el-button>
      </span>
    </el-dialog>

    <el-dialog title="填写状态明细" :visible.sync="searchAllStatusDialog" width="36%">
          <div label="" style="padding:10px 0;display: flex;">
          <el-link type="primary" >{{searchName||'请选择评价人'}}</el-link>
        </div>
        <div class="transferWrap" style="display: flex;margin-top: 10px;justify-content: space-between;overflow: auto;padding-bottom: 20px;margin-bottom: 20px;">
          <div class="el-transfer-panel add-transfer" v-for="(it, key) in searcData" v-bind:key="key">
            <div class="el-transfer-panel__header"
              style="display: flex;padding-right: 15px;justify-content: space-between;">
              <div>{{it.name}}</div>
            </div>
            <div style="margin: 20px;height:300px;overflow-y: auto; margin-right: 10px;padding-right: 10px;">
              <div v-for="(item, index) in it.children" :key="index" class="oneChangedStu">
                <div>{{item.name}}</div>
                <el-link :type="item.class">{{item.status== 0?'待评价':'已评价'}}</el-link>
              </div>
            </div>
            <!-- <p class="el-transfer-panel__footer">== 0?'待评价':'已评价'
              <el-button size="mini" type="primary" plain :title="'为【'+it.label_title+'】添加被评价对象'"
                :loading="nowLabelLoading" @click="handleAdd(it)">添加</el-button>
              <el-button type="danger" size="mini" @click="removeAllTeacher(it)"
                :title="'清空【'+it.label_title+'】已添加被评价对象'">清空</el-button>
            </p> -->
          </div>
        </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  name:'planStatistics',
  data() {
    return {
      loading: false,
      allSN: {},
      activeName: 'first',
      isStatusStr: {0: '停止', 1: '草稿', 2: '待发布', 3: '发布中'},
      allQType: {1: '单选题', 2: '多选题', 3: '问答题'},
      tableData: [],
      id: '',
      // 评价人a总数
      aTotal: 0,
      searchA: {
      'plan_id': '',
      'grade_id': '',
      'class_id': '',
      'dept_id': '',
      'is_finish': '',
      'class_ids': '',
      'pageNo': 1,
      'pageSize': 10
      },
      searchB: {
      'plan_id': '',
      'grade_id': '',
      'class_id': '',
      'dept_id': '',
      'is_finish': '',
      'pageNo': 1,
      'pageSize': 10
      },
      // 所有班级数组
      allGrade: [],
      // 所有年级班级Obj
      allClass: {},
      allDep: {},
      // 评价人下拉所有的部门
      allLeftDep: [],
      // 被评价人下拉所有的部门
      allRightDep: [],
      // 当前选中的年级
      getNowAllClass: [{
        label: '全部班级',
        value: ''
      }],
       // 当前选中的年级-被评价人
       getBNowAllClass: [{
        label: '全部班级',
        value: ''
      }],
      // 添加评价人表单---树
      // 树的配置
      defaultProps: {
        children: 'children',
        label: 'label'
      },
      addForm: {
        id: '',
        name: '',
        to: []
      },
      // 添加评价人加载标识
      addLoading: true,
      // 添加评价人---打开添加评价人窗口
      addDialogView: false,
      // 添加评价人---打开选择评价人窗口
      addAppraiserDialog: false,
      // 搜索关键字（评价人名字）
      appraiserFilterText: '',
      // 添加评价人---评价人数据
      appraiserDialogData: [],
      nowLabel: {},
      nowLabelLoading: false,
      // 添加被评价人---打开选择被评价人窗口
      addBeEvaluatedDialog: false,
      // 添加被评价人---搜索关键字（被评价人(教师)名字）
      filterText: '',
      // 添加被评价人---评价人（教师）数据
      teachers: [],
        // 添加被评价人--已选的发布对象(范围)
      changedObj: [],
      // 添加被评价人--全选
      checkAll: false,
      nowPlan: {
        'password': '',
        'eval_from_to': '',
         'is_self_eval': 1,
        'plan_title': '',
        'status': '',
        'id': ''
      },
      // 密码相关 窗口 表单
      dialogPSVisible: false,
      PSForm: {
        password: ''
      },
      rules: {
        password: [
            { required: true, message: '请输入访问密码', trigger: 'blur' }
          ]
       },
       // 是否校验过密码
       PSChecked:'',
       tableRightData: [],
      // 评价人b总数
      bTotal: 0,
      // 表头
      tabledHead: [],
      // 计划类型 学生/老师
      planType: 1,
      // 当前查看的评价详情
      statisticsObj: {
        planId: '',
        evaluatedId: '',
        studentName: '',
        labelId: ''
      },
      // 统计详情
      dialogStatisticsIsible: false,
      // 统计所有的标签
      allLabels: [],
      editableTabsValue: '1',
      // 问卷
      questionData: [],
      // 提交人明细表窗口
      dialogSubmitterIsible: false,
      // 提交人明细表-当前查看的选项
      submitterTabsValue: '',
      // 提交人明细表-所有选项
      allOPLabels: [],
      // 提交人列表--提交人明细
      submitterData: [],
      // 被评价人详情加载标识
      submitterLoading: false,
      nowQuestion: '',
      // 当前查看的被评价人
      nowViewTeacher: {
          name: '',
          mob: ''
      },
      // 所有已选择的评价人
      allChangedIds: [],
      count: 0,
      times: false,
      admin:false,
      // 填写状态明细 状态查询，
      searchAllStatusDialog:false,
      searcData:{},
      searchName:'LIU'
    }
  },
  watch: {
    appraiserFilterText(val) {
        this.$refs.tree.filter(val)
      },
    filterText(val) {
        this.$refs.teacherTree.filter(val)
      }
    },
  mounted() {
    debugger
    const _this=this
    const parameter=window.location.hash.split('?')[1].split('&')
    const nowPlan = parameter[0].split('=')[1]
    _this.nowPlan.completion_ratio = parameter[1].split('=')[1]
    _this.admin = parameter[2].split('=')[1]==='1'

      // 获取计划id
    _this.searchA.plan_id = nowPlan
    _this.searchB.plan_id = nowPlan
    _this.statisticsObj.planId = nowPlan
    _this.id=nowPlan

    // 获取左侧列表(查询下拉列表)
    if(!_this.admin){
      _this.dealLocalData(function(){
        // 获取左侧列表(查询下拉列表)
        _this.selectOption()
      })
    }else{
      _this.selectOption()
    }
  
    // 获取计划详情
    _this.getPlanDetail()
    // 获取评价人列表
    _this.list()
    // 缓存密码
    debugger
    if(sessionStorage.PSChecked){
      _this.PSForm.password = sessionStorage.PSChecked
    }
    
    // 获取右侧被评价列表
    _this.rightList()
    // 获取左侧列表(查询下拉列表)
    _this.selectRightOption()
    //  生成26个字母
    for (let i=0; i<26; i++) {
        // 输出A-Z  26个大写字母
        _this.allSN[i]=String.fromCharCode(65 + i)
    }
      // 监听键盘事件
      window.addEventListener('keydown', (event) => {
        // 检查按键是否为 "3"
        if (event.key === '3') {
          _this.count++ // 增加计数器
        } else {
          // 如果按键不是 "3"，则重置计数器
          _this.count = 0
        }
         // 当计数器达到5时，执行所需的操作
        if (_this.count === 5) {
          _this.times=!_this.times
          _this.count=0
          // 这里可以执行你需要的操作
          setTimeout(() => {
            _this.count=0
          }, 100)
        }
      })
  },
  methods: {
    allBack(){
      const _this=this
      _this.loading = true
    const promise1 = new Promise((resolve, reject) => {
      _this.selectOption(() => { resolve('1') })
      })
       // 获取计划详情
      const promise2 = new Promise((resolve, reject) => {
        _this.getPlanDetail(() => { resolve('2') })
      })
      
      // 获取评价人列表
      const promise3 = new Promise((resolve, reject) => {
        _this.list(() => { resolve('3') })
      })
      // 获取右侧被评价列表
      const promise4 = new Promise((resolve, reject) => {
        _this.rightList(() => { resolve('4') })
      })
      // 右侧下拉
      const promise5 = new Promise((resolve, reject) => {
        _this.selectRightOption(() => { resolve('5') })
      })

      const allPro=[promise1, promise2, promise3, promise4, promise5]
      Promise.all(allPro)
        .then((values) => { this.loading = false })
        .catch((error) => console.log(error))
    },
    back() {
      window.location.href='#x41'
    },
    handleClick(tab, event) {
      console.log(tab, event)
    },
      // 分页操作-修改显示页数-每页显示指定条数
    handleSizeChange (e) {
      this.searchA.pageNo = 1
      this.searchA.pageSize = e
      this.list()
    },
    handleORSizeChange (e) {
      debugger
      this.searchB.pageNo = 1
      this.searchB.pageSize = e
      this.rightList()
    },
    // 分页操作-跳转到指定页 跳转到指定页数
    handleCurrentChange (e) {
      this.searchA.pageNo = e
      this.list()
    },
    handleORCurrentChange(e){
     this.searchB.pageNo = e
      this.rightList()
    },
    // 查询评价人列表所有的ids
    async getAllChangedIds(okFun) {
      this.loading = true
      const res = await this.$api.plan.getAllChangedIds.get({
          'plan_id': this.id
      })
      this.loading = false
      if (res.code === 200) {
         this.allChangedIds = res.data
         if (okFun)okFun()
      } else {
          this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
      }
    },
    // 添加评价人--打开添加评价人窗口--查询已选的人列表--先查询标签
    async add() {
      this.addLoading = true
      new Promise((resolve, reject) => {
        this.getAllChangedIds(() => {
          resolve(1)
        })
      }).then(async (data) => {
            const res = await this.$api.plan.labelList.get({
                'plan_id': this.id
            })
            this.addLoading = false
            if (res.code === 200) {
                this.addForm.to = res.data.map(item => {
                  return {
                    'label_title': item.label_title,
                    'label_id': item.label_id,
                    'add': []
                  }
                })
                this.addDialogView=true
            } else {
                this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
            }
      })
    },
    // 选择被评价人--打开窗口
    // type 1 评价人 2被评价人
    addAppraiser(type) {
        if (type===2) {
            if (this.teachers.length===0) {
                // 教师评教师
            new Promise((resolve, reject) => {
              this.getDepTeacher((data) => {
                resolve(1)
                this.appraiserDialogData=data
              })
            }).then((data) => {
              this.addBeEvaluatedDialog=true
            })
            }
        } else {
          // 判断计划类型--1学生/老师 2老师/老师
          if (this.nowPlan.eval_from_to) {
            // 学生评老师
            // 获取评价人 和被评价人
            this.addLoading = true
            const promise1 = new Promise((resolve, reject) => {
            this.getGrade(() => { resolve('1') })
            })
            const promise2 = new Promise((resolve, reject) => {
            this.getDepTeacher(() => { resolve('2') })
            })

            const allPro=[promise1, promise2]
            Promise.all(allPro)
            .then((values) => {
              this.addLoading = false
              this.addAppraiserDialog=true
            })
            .catch((error) => console.log(error))
          } else {
            // 教师评教师
            new Promise((resolve, reject) => {
            this.getDepTeacher((data) => {
              resolve(1)
              this.appraiserDialogData=data
              console.log(data)
            })
            }).then((data) => {
            console.log(data)
            this.addAppraiserDialog=true
            })
          }
       }
    },
    // 树-添加选择按钮--添加评价人
    renderContent(h, { node, data, store }) {
      console.log(data)
       let htmlStr=''
        if (data.children !== undefined) {
          htmlStr=(
          <span class="custom-tree-node">
            <span class='studentName'>{node.label}</span>
          </span>)
        } else if (data.disabled) {
          htmlStr=(
          <span class="custom-tree-node">
            <span class='studentName'>{node.label}</span>
            <span class='treeOperation'>
              <el-link disabled>已添加</el-link>
            </span>
          </span>)
        } else {
          htmlStr=(
          <span class="custom-tree-node">
            <span class='studentName'>{node.label}</span>
            <span class='treeOperation'>
              <el-link type="primary" on-click={ () => this.append(data) }>选择</el-link>
            </span>
          </span>)
        }
        return htmlStr
    },
    // 评价人列表--已选择的评价人回显
    append(data) {
      // 关闭窗口
      this.addForm.id=data.id
      this.addForm.name=data.label+'('+ data.parent+')'
      this.addAppraiserDialog=false
    },
    // 树-过滤--添加评价人和被评价人-公用
    filterNode(value, data) {
      if (!value) return true
      return data.label.indexOf(value) !== -1
  },
    // 被评价人-----------操作

    // 被评价人--操作--打开被评价人选择窗口
    handleAdd(labelInfo) {
      debugger
      this.nowLabel=labelInfo
      this.checkAll=false
      if (this.teachers.length===0) {
             this.nowLabelLoading=true
                // 教师评教师
            new Promise((resolve, reject) => {
              this.getDepTeacher((data) => {
                resolve(1)
              })
            }).then((data) => {
              this.nowLabelLoading=false
              this.changedObj=this.nowLabel.add
              this.addBeEvaluatedDialog=true
              this.$refs.teacherTree.setCheckedKeys([])
            })
      } else {
        let added=[]
        this.changedObj=this.nowLabel.add
        if(this.changedObj.length>0){
          added = this.changedObj.map(item => item.id)
        }
        this.addBeEvaluatedDialog=true
        this.$refs.teacherTree.setCheckedKeys(added)
      }
    },
    //  被评价人----树-操作-单选
    handleNodeClick(data, all) {
        const setIds = this.teachers.map(item => item.id)
        if (setIds.every(item => all.checkedKeys.includes(item))) {
            // console.log('arrayB包含于arrayA中')
            this.checkAll=true
        } else {
            // console.log('arrayB不包含于arrayA中')
            this.checkAll=false
        }
        this.changedObj=[]
        this.$refs.teacherTree.getCheckedNodes().map(item => {
            if (!item.children) {
                this.changedObj.push(item)
            }
        })
      },
      //  被评价人----树-操作-全选
      handleCheckAllChange() {
          const setIds=this.teachers.map(item => item.id)
          this.$refs.teacherTree.setCheckedKeys(this.checkAll?setIds:[])
          this.$nextTick(() => {
              this.changedObj=[]
              this.$refs.teacherTree.getCheckedNodes().map(item => {
                  if (!item.children) {
                      this.changedObj.push(item)
                  }
              })
          })
      },
      //  被评价人----树-操作-清空
      resetChecked() {
          this.checkAll=false
          this.$refs.teacherTree.setCheckedKeys([])
          this.changedObj=[]
      },
       //  被评价人----树-操作-右侧移除
      remove(id) {
          const filteredArray = this.changedObj.filter(item => item.id !== id)
          this.changedObj=filteredArray
          const setIds=this.changedObj.map(item => item.id)
          this.$refs.teacherTree.setCheckedKeys(setIds)
      },
      // 当前标签已选择教师删除
      removeNowTeacher(index, all) {
        all.splice(index, 1)
      },
      removeAllTeacher(all) {
        all.add=[]
        console.log(all)
      },
      // 确认已选择的被评价人(教师)
      sureTeachers() {
        this.nowLabel.add=this.changedObj
        this.addBeEvaluatedDialog=false
      },
    // 被评价人------------end
    // 获取所有年级班级及学生--添加评价人用
    async getGrade(okFun) {
            const res = await this.$api.base.getAllGradeClassStudents.get({
              isAdmin: 1,
              supperAdmin: 1,
              from_src: 'fwh',
              returnStudent: 1
          })
          if (res.code === 200) {
                this.students=[]
                res.data.map((item, index) => {
                  const gradeObj = {
                      id: item.grade_number,
                      nid: item.grade_id,
                      label: item.grade_name,
                      children: []
                  }
                  if (item.classes.length > 0) {
                      item.classes.map(it => {
                          const classObj = {
                              id: it.clas_id,
                              nid: it.clas_id,
                              label: it.clas_name,
                              parent: gradeObj.label
                          }
                          if (it.students && it.students.length > 0) {
                              classObj['children']=[]
                              it.students.map(ite => {
                                  const studentObj = {
                                      id: ite.stud_id,
                                      nid: ite.stud_id,
                                      label: ite.stud_name,
                                      parent: item.grade_name+classObj.label,
                                      disabled: this.allChangedIds.includes(ite.stud_id)
                                  }
                                  classObj.children.push(studentObj)
                              })
                              gradeObj.children.push(classObj)
                          }
                      })
                      this.appraiserDialogData.push(gradeObj)
                  }
              })
              console.log(this.appraiserDialogData)
              if (okFun)okFun()
          } else {
              this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
          }
      },
    // 获取所有部门及教师--添加被评价人用
    async getDepTeacher(okFun) {
             const res = await this.$api.base.getDepTeacher.get({})
            if (res.code === 200) {
              this.teachers=[]
                  res.data.map(item => {
                    const depObj = {
                        id: item.deptId,
                        label: item.deptName,
                        children: []
                    }
                    item.deptTechList.map(it => {
                        const teacherObj = {
                            id: it.user_id,
                            label: it.tech_name,
                            mob: it.user_mobile,
                            parent: it.user_mobile
                        }
                        depObj.children.push(teacherObj)
                    })
                    this.teachers.push(depObj)
                })
                 console.log(this.teachers)
                if (okFun)okFun(JSON.parse(JSON.stringify(this.teachers)))
            } else {
                this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
            }
    },
    // 查看被评价人访问控制
    goSecond() {
      debugger
      if (this.PSChecked ==='') {
        if (sessionStorage.identity === '99' || this.nowPlan.password==='') {
            this.activeName = 'second'
        } else {
          this.dialogPSVisible = true
        }
      } else {
        this.activeName = 'second'
      }
    },
    // 访问校验
    verifyPS() {
      let canSaveFlag = false
      this.$refs['PSForm'].validate((valid) => {
          if (valid) {
              canSaveFlag = true
          }
      })
      if (!canSaveFlag) {
          return false
      }
      if (this.PSForm.password===this.nowPlan.password) {
          this.dialogPSVisible = false
          this.activeName = 'second'
          this.PSChecked = this.nowPlan.password
          sessionStorage.PSChecked = this.PSForm.password
      } else {
        this.$alert('输入的密码不正确，请仔细检查', '提示', { type: 'warning', closeOnHashChange: !1 })
      }
    },
    // 获取评价人列表
    async list (okFun) {
      this.loading = true
      const res = await this.$api.plan.evaluaters.get(this.searchA)
      if (res.code === 200) {
        this.tableData = res.data?res.data.paging.data:[]
        this.loading = false
        // 分页
        this.aTotal = res.data?res.data.paging.total:0
        if (okFun) { okFun() }
      } else {
        this.loading = false
        this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
      }
    },
    // 获取计划下拉列表
    async getPlanDetail(okFun) {
      debugger
        const res = await this.$api.plan.detail.get({
            'plan_id': this.id,
            'class_ids':this.class_ids
        })
        if (res.code === 200) {
             // 获取计划类型 及密码
          // this.nowPlan=res.data
          this.nowPlan.password = res.data.password
          this.nowPlan.eval_from_to = res.data.eval_from_to ==='学生/教师'
          this.nowPlan.id=res.data.id
          this.nowPlan.status=res.data.status
          this.nowPlan.is_self_eval=res.data.is_self_eval

          this.nowPlan.completion_ratio=res.data.completion_ratio||'0/0'
          this.nowPlan.plan_title=res.data.plan_title
          this.nowPlan.is_hidden=res.data.is_hidden===1
          // console.log(this.nowPlan)
          if (okFun) { okFun() }
        } else {
            this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
        }
    },
    // 重置搜索条件
    reList () {
      this.searchA.pageNo = 1
      this.list()
    },
    // 年级搜索
    gradeChange(val) {
      debugger
      this.getNowAllClass= [{
        label: '全部班级',
        value: ''
      }]
      this.getNowAllClass = this.getNowAllClass.concat(val==''?[]:this.allGrade.find(item => item.value === val).children)
      this.searchA.class_id=''
      this.searchA.search_class = this.getNowAllClass[0].value
      this.searchA.pageNo = 1
      this.list()
    },
    // 被评价人年级搜索
    depChange(val) {
      this.searchB.dept_id = val
      this.searchB.pageNo = 1
      this.rightList()
    },
    // 本地数据生成班主任任课
    dealLocalData(okFun) {
      const mapBZR = JSON.parse(sessionStorage.getItem('mapBZR'))
      const classIds=[]
      mapBZR.map(item => {
        classIds.push(item.clas_id)
      })
      this.class_ids=classIds.join(',')
      this.searchA.class_ids=classIds.join(',')
      if (okFun) { okFun() }
    },
    // 分页操作-修改显示页数-每页显示指定条数
    handleBSizeChange (e) {
      this.searchB.pageNo = 1
      this.searchB.pageSize = e
      this.rightList()
    },
    // 分页操作-跳转到指定页 跳转到指定页数
    handleBCurrentChange (e) {
      this.searchB.pageNo = e
      this.rightList()
    },
    handleRightDetail(obj) {
      this.allLabels=[]
      this.statisticsObj.evaluatedId = obj.id
      this.statisticsObj.labelId = obj.labelId||''
      this.statisticsObj.studentName=obj.key0
      this.rightDetail()
    },
    // 更新被评价人状态
    async refresh(obj) {
      const parameter = {
        planId: this.id,
        evaluatedId: obj.id
      }
      const res = await this.$api.plan.evaluatedersDeail.get(parameter)
      this.loading = false
      if (res.code === 200) {
        console.log(res)
      } else {
        this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
      }
    },
    // 获取被评价人列表
    async rightList (okFun) {
      this.loading = true
      const res = await this.$api.plan.evaluateders.get(this.searchB)
      if (res.code === 200) {
        this.tabledHead = []
        // 生成表头
        res.data.headList.map((item, index) => {
            this.tabledHead.push({'key': 'key' + index, 'title': item})
        })
        let allDealData = []
        res.data.paging.data.map((item) => {
          let dealData = {}
          item.map((it, index) => {
            if (index===0) {
              dealData['id'] = it
            } else {
              dealData['key' + (index-1)] = it
            }
          })
          allDealData.push(dealData)
        })
        this.tableRightData = allDealData
        this.loading = false
        // 分页
        this.bTotal = res.data.paging.total
        if (okFun) { okFun() }
      } else {
        this.loading = false
        this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
      }
    },
      // 获取被评价人列表--评价详情
    async rightDetail (obj) {
      const res = await this.$api.plan.evaluatedersDeail.get(this.statisticsObj)
      if (res.code === 200) {
         console.log(res)
         const nowView={
          name: res.data.techName,
          mob: res.data.techMobile
         }
         debugger
         this.nowViewTeacher=nowView
         const dealQuestionData=[]
         res.data.qaVoList.map((item, i) => {
              const op = item.questionOptionVoList// JSON.parse(item.questionOptionVoList)
              if(item.type==3){
                op[0].question_id=item.question_id
                op[0].question_option_title='问答题'
              }
              op.map((it, index) => {
                const oneQu =Object.assign({
                  'question_id': item.question_id,
                  'model_id': item.model_id,
                  'type': item.type,
                  'option': op,
                  'is_required': item.is_required,
                  'SN': (i+1),
                  'questionOptionId': it.questionOptionId,
                  'index': index,
                  'question_title': item.question_title,
                  'description': item.description
                }, it)
                dealQuestionData.push(oneQu)
              })
          })
          // 问题显示
          this.questionData = dealQuestionData
          // 标签显示
          if(this.allLabels.length==0){
            const dealData= res.data.labelList.map((item, i) => {
              if (i===0) {
                  this.editableTabsValue= item.id.toString()
                }
              return {
                planId: item.plan_id,
                evaluatedId: this.statisticsObj.evaluatedId,
                studentName: this.statisticsObj.studentName,
                name: item.label_title,
                labelId: item.id.toString(),
                loaded: false
              }
            })
            this.allLabels = dealData
          }
          if(this.statisticsObj.labelId===''){
            this.editableTabsValue =res.data.labelList[0].id.toString()
          }
          // 加载完毕则标记load完成
            if (obj) {
              obj.loaded=true
            }
         this.dialogStatisticsIsible = true
      } else {
        this.loading = false
        this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
      }
    },
    // 获取选项的提交人明细
    // type
    async submitterInfo (obj, type) {
      this.submitterLoading=true
      let nowOption=null
      
      if(obj.type==3){
        this.submitterTabsValue='0'
      }
     
      console.log(this.nowPlan)
      if (type) {
        this.nowQuestion=obj.SN +'. '+ obj.question_title
        this.allOPLabels=[]
        obj.option.map((item,index) => {
          const optionObj={
            id: item.questionOptionId==null||obj.type==3?'':item.questionOptionId.toString(),
            pageNo: 1,
            pageSize: 10,
            total: 0,
            type:obj.type,
            planId: this.statisticsObj.planId,
            questionId: obj.question_id,
            labelId: this.editableTabsValue,
            evaluatedId: this.statisticsObj.evaluatedId,
            name: item.question_option_title,
            questionOptionId: item.questionOptionId==null||obj.type==3?'':item.questionOptionId.toString(),
            loaded: false,
            show_dept_name: false,
            data: []
          }
          if(index==0){
            nowOption=optionObj
          }
         
          if (obj.questionOptionId !=='' && obj.questionOptionId !== null && obj.questionOptionId === item.questionOptionId) {
            this.submitterTabsValue=item.questionOptionId.toString()
          }
          this.allOPLabels.push(optionObj)
        })
      } else {
        nowOption=obj
      }
      this.dialogSubmitterIsible=true
      const res = await this.$api.plan.submitterList.get(nowOption)
      this.submitterLoading=false
      if (res.code === 200) {
         console.log(res)
         nowOption.total=res.data.paging.total
         nowOption.data=res.data.paging.data
         nowOption.loaded=true
         if(res.data.paging.data.length>0){
          nowOption.show_dept_name=res.data.paging.data[0].dept_name!==null
         }
         this.dialogSubmitterIsible=true
          if (obj) {
            obj.loaded=true
          }
         this.dialogStatisticsIsible = true
      } else {
        this.loading = false
        this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
      }
    },
    // 删除评价人
     handleDel (info) {
       this.$confirm('删除评价人将会清空其所填写的评价信息，且数据不可恢复，请谨慎操作，是否删除?', '提示', {
         confirmButtonText: '删除',
         cancelButtonText: '取消',
         type: 'warning'
       }).then(async () => {
            const delPr = {
              plan_id: info.plan_id,
              evaluator_id: info.id
            }
            const res = await this.$api.plan.delEvaluator.post(delPr)
            if (res.code === 200) {
                this.allBack()
                this.$alert('删除成功！', '提示', { type: 'success', closeOnHashChange: !1 })
            } else {
              this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
            }
       }).catch(() => {
       })
    },
    // 提交人明细切换
    handleTabsclick(tab, event) {
      const clickedTab = this.allOPLabels.find(t => t.id === tab.name)
      if (!clickedTab.loaded) {
        // 模拟异步加载数据
        this.submitterInfo(clickedTab)
      }
    },
    // 提交人明细-分页-显示条数变化
    submitterSizeChange(e,obj) {
      obj.pageNo = 1
      obj.pageSize = obj
      obj.data=[]
      this.submitterInfo()
    },
    // 提交人明细-分页-页数变化
    submitterCurrentChange(e,obj) {
      obj.data=[]
      obj.pageNo = e
      this.submitterInfo(obj)
    },
    // 统计弹窗--表格合并
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      // console.log('行', rowIndex)
      // console.log('列', columnIndex)
        if (columnIndex === 0 || columnIndex === 1 || columnIndex === 5) {
          if (row.index === 0) {
            return {
              rowspan: row.option.length,
              colspan: 1
            }
          } else {
            return {
              rowspan: 0,
              colspan: 0
            }
          }
        }
      },
    // 统计弹窗--计划标签-切换标签 查询标签详情
    handleTabsEdit(tab, event) {
      const clickedTab = this.allLabels.find(t => t.labelId === tab.name)
      console.log(this.editableTabsValue)
      this.statisticsObj=Object.assign(this.statisticsObj,clickedTab)
      if (!clickedTab.contentLoaded) {
        this.rightDetail()
      }
    },
    // 新增评价人保存
    // 获取查询下拉列表
    async addAll () {
        if (this.addForm.id==='') {
        this.$alert('请选择一位评价人', '提示', { type: 'warning', closeOnHashChange: !1 })
        return false
       }

       // 是否可以自评
       let selfFlag= Number(this.nowPlan.is_self_eval) === 0
       let isRepeat=false
       const allIds=[]
       let toArray=[]
       this.addForm.to.map(item => {
        toArray = toArray.concat(item.add)
        // 判断是否 重复
        item.add.map(item => {
          if (this.addForm.id === item.id && selfFlag) {
            isRepeat=true
          }
        })
         const obj={
          labelId: item.label_id,
          addIds: item.add.map(it => it.id).join(',')
         }
         // 只传选人的标签
         if (obj.addIds!=='') {
          allIds.push(obj)
         }
       })
       if(toArray.length==0){
        this.$alert('至少选择一个评价人！', '提示', { type: 'warning', closeOnHashChange: !1 })
        return false
       }
       // 如果不能自评则弹提示
       if (isRepeat) {
         this.$alert('因该计划不支持自评，故填写人不可出现在被评价人列表中', '提示', { type: 'warning', closeOnHashChange: !1 })
         return false
       }

      const parameters={
        'plan_id': this.id,
        'evaluator_user_id': this.addForm.id,
        'evaluated_json': JSON.stringify(allIds)
      }
      this.addLoading = true
      const res = await this.$api.plan.addEvaluaters.post(parameters)
      this.addLoading = false
      if (res.code === 200) {
        this.allBack()
        this.addDialogView=false
        this.$alert('添加成功', '提示', { type: 'success', closeOnHashChange: !1 })
      } else {
        this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
      }
    },
    // 获取左侧select
    async selectOption (okFun) {
      const res = await this.$api.plan.seachOption.get({
        plan_id: this.id,
        class_ids:this.class_ids
      })
      if (res.code === 200) {
        if (res.data.dept_list.length>0) {
          this.planType=1
          this.allLeftDep=[{
            label: '全部部门',
            value: ''
          }]
          res.data.dept_list.map(item => {
            const depObj = {
              label: item.dept_name,
              value: item.dept_id
            }
            this.allLeftDep.push(depObj)
          })
        } else {
          this.planType=2
          this.allGrade=[{
            label: '全部年级',
            value: ''
          }]
          for (let ite in res.data.grade_class) {
            const item=res.data.grade_class[ite]
            const gradeObj = {
              label: item.grade_name,
              value: item.grade_id,
              children: []
            }
            item.class_list.map(it => {
               const classObj={
                label: it.class_name,
                value: it.class_id
               }
               gradeObj.children.push(classObj)
            })
            this.allGrade.push(gradeObj)
          }
        }
        console.log(this.allGrade)
        if (okFun) { okFun() }
        //  console.log(res.data.dept_list.length)
        //  console.log(Object.values(res.data.grade_class).length)
      } else {
        this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
      }
    },
    async selectRightOption (okFun) {
      const res = await this.$api.plan.seachRightOption.get({plan_id: this.id})
      if (res.code === 200) {
          this.allRightDep=[{
            label: '全部部门',
            value: ''
          }]
          res.data.map(item => {
            const depObj = {
              label: item.dept_name,
              value: item.dept_id
            }
            this.allRightDep.push(depObj)
          })
           if (okFun) { okFun() }
      } else {
        this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
      }
    },
    async getAllStatus (obj) {
      this.searchName=obj.user_name
      const res = await this.$api.plan.seachStatus.get({plan_id: this.id,login_user_id:obj.user_id})
      if (res.code === 200) {
          console.log(res.data)
          const labelTree={}
          res.data.list.forEach(item=>{
            if(!labelTree[item.label_id]){
              const dealObj={
                name:item.label_title,
                children:[{
                  name:item.user_name+'('+item.user_mobile+')',
                  dep:item.dept_name,
                  status:item.is_finish,
                  class:item.is_finish==1?'success':'danger' 
                }]
              }
              labelTree[item.label_id]=dealObj
            }else{
              labelTree[item.label_id].children.push({
                name:item.user_name+'('+item.user_mobile+')',
                dep:item.dept_name,
                status:item.is_finish,
                class:item.is_finish==1?'success':'danger'
              })
            }
            this.searchAllStatusDialog=true
            console.log(labelTree)
            this.searcData=labelTree
          })

      } else {
        this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
      }
    },
    async downFile (type) {
      var str = this.nowPlan.plan_title + new Date().toLocaleString().replace(/[/\s:]/g, '') + '.xlsx'
      const parameter = {
        'org_id': sessionStorage.org_id,
        'token': sessionStorage.token,
        'udid': sessionStorage.udid,
        'fileName': encodeURIComponent(str)
      }
      const downParameter = Object.assign(parameter, this.searchB)

        // 原始写法 新的是以流的方式下载，本地生成文件
         // window.location.href = (type === 1 ? this.$api.plan.downList.url : this.$api.plan.downImg.url) + '?' + this.parseParams(downParameter)
        // var url = type === 1 ? this.$api.planDetail.downTemplate.down(downParameter) : this.$api.planDetail.downExcel.down(downParameter)
        // const res = await url
        const res = await this.$api.plan.downSList.get(downParameter, null)
        console.log(res)
    },
    // 格式化参数【下载】下载用
    parseParams (data) {
      try {
        let tempArr = []
        for (let i in data) {
          let key = encodeURIComponent(i)
          let value = encodeURIComponent(data[i])
          tempArr.push(key + '=' + value)
        }
        let urlParamsStr = tempArr.join('&')
        return urlParamsStr
      } catch (err) {
        return ''
      }
    }
  }
}
</script>
<style>
.wrap {
  background: #fff;
  padding: 10px;
}
.tabHead {
  border-bottom: 1px solid #e4e7ed;
}
.tabHead .tabHeadTab{
    border: 1px solid #e4e7ed;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    box-sizing: border-box; width: 300px;
}
.tabHead .tabHeadTab  .el-tabs__item {
    border-bottom: 1px solid transparent;
    border-left: 1px solid #e4e7ed;
    transition: color .3s cubic-bezier(.645,.045,.355,1),padding .3s cubic-bezier(.645,.045,.355,1);
}
.tabHead .tabHeadTab .el-tabs__item:first-child {
    border-left: none;
}
.el-tabs__item.is-active {
    color: #409eff;
}
.el-table {
  margin-bottom: 15px;
}
.red {
  color: #f30;
}
.green {
  color: rgb(18, 187, 69);
}
.planTitleWrap {
  padding: 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#statisWrap {
  min-height: 480px;
}
#statisWrap .el-tabs__header.is-top {
  display: block;
}
.el-dialog__body {
  padding-top: 0;
}
#statisWrap .el-tabs__nav-wrap::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background-color: #E4E7ED;
    z-index: 1;
}
#statisWrap .el-tabs__nav-scroll {
  text-align: justify;
    padding: inherit;
    background: none;
    border-bottom: none;
}
#statisWrap .el-tabs__nav {
  overflow: auto;
  width: 100%;
}
.teacherInfoWrap {
  padding: 10px 0;
}
.teacherInfoWrap i{
  font-size: 1.5rem;
  color: #d2d2d2;
}
.teacherInfoWrap .teacherName {
  font-size: 16px;
  font-weight: bold;
  margin: 0 5px;
}
.add-transfer .transfer-footer {
    margin-left: 15px;
    padding: 6px 5px;
}
.add-transfer .el-empty {
  padding: 0;
}
.el-transfer-panel .el-transfer-panel__footer {
  padding: 0 10px;
}
.el-transfer-panel .el-button{
  padding: 4px 8px;
}
.oneChangedStu {
  display: flex;
  justify-content: space-between;
  line-height: 30px;
}
.oneChangedStu .remark {
        color: #aaa;
    }
.el-transfer-panel {
  width: 280px;
  min-width: 260px;
  margin-right: 3px;
}
.treeOperation {
  padding: 0 20px;
}
.studentName {
  width: 90px;
  display: inline-block;
}
#statisWrap .el-dialog__body {
  min-height: 50px;
}
#statisWrap .el-form--label-top .el-form-item__label {
 padding-bottom: 0;
}
.el-tabs__content{
  overflow: auto;
}
</style>
